using System;
using Core.Guide;
using Core.Step;
using Modules.UI.Main;
using Toolkit.AudioExtend;
using UnityEngine;
using Utils;
using Utils.Singleton;

namespace Managers
{
    /// <summary>
    /// 游戏管理器类，负责游戏的主要管理逻辑。
    /// </summary>
    public partial class GameManager : MonoSingleton<GameManager>
    {
        protected override bool NotDestroyed => true;

        public ModuleType ModuleType { get; set; } = ModuleType.Study;

        private Configs _configs; // 配置表

        protected override void OnSingletonInitialized()
        {
            _configs = new Configs();
        }


        #region 导航器

        public GuideSystem GuideSys { private set; get; }

        public GuideSystem NewGuideSys()
        {
            GuideSys = new GuideSystem(_configs.Guides());
            return GuideSys;
        }

        #endregion

        #region 步骤

        public StepSystem StepSys { private set; get; }

        public StepSystem NewStepSys()
        {
            StepSys = new StepSystem(_configs.Steps()); // 根据注册器初始化步骤管理器
            return StepSys;
        }

        #endregion

        #region 编辑器下步骤提示

#if UNITY_EDITOR
        private void OnGUI()
        {
            StepBase step = StepSys?.Current;
            if (step == null)
                return;

            float width = Screen.width * 0.2f;

            GUIStyle style = new GUIStyle();
            style.normal.textColor = Color.cyan;
            style.fontSize = 20;
            style.fontStyle = FontStyle.Bold;
            style.alignment = TextAnchor.MiddleCenter;
            GUI.backgroundColor = Color.black;

            GUI.Box(new Rect(10, 10, width, 40), $"");
            GUI.Label(new Rect(10, 10, width, 40), $"{step.StepNumber}-{step.SubNumber}  {step.Name}", style);
        }
#endif

        #endregion
    }
}